<script setup>
import { Menu } from '@element-plus/icons-vue';
import { useHomeDataStore } from '../stores/index.js';
import componentTags from '../components/tags.vue';

const getImageUrl = (user) => {
  return new URL(`../assets/images/user.png`, import.meta.url).href;
};
const store = useHomeDataStore();
const handleCollapse = () => {
  store.state.isCollapse = !store.state.isCollapse;
};
</script>

<template>
  <div class="header" style="width: 100%">
    <div class="l-content">
      <el-button size="small" @click="handleCollapse" style="margin-left: 10px">
        <!-- 这个注意图标 -->
        <el-icon> <Menu /> </el-icon>
      </el-button>

      <el-breadcrumb separator="/" class="bread">
        <el-breadcrumb-item :to="{ path: '/' }">
          <span style="color: white">首页</span>
        </el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="r-content">
      <el-dropdown>
        <span class="el-dropdown-link">
          <img :src="getImageUrl(user)" class="user" />
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>个人中心</el-dropdown-item>
            <el-dropdown-item>退出</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<style scoped lang="less">
.header {
  display: flex; /* 使用 flex 布局 */
  justify-content: space-between; /* 左右两部分内容均匀分布 */
  align-items: center; /* 垂直居中对齐 */
  width: 100%;
  padding: 2px 10px; /* 更小的 padding 值 */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), 0 -4px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid rgb(209, 209, 209);
  height: 60px; /* 更小的高度 */
}

.l-content {
  display: flex;
  align-items: center; /* 使内容垂直居中 */
}

.r-content {
  display: flex;
  justify-content: flex-end; /* 使右侧内容对齐到最右边 */
}

.user {
  width: 40px; /* 更小的头像 */
  height: 40px;
  border-radius: 50%;
}
</style>
